<%@ page language="java" contentType="text/html; charset=US-ASCII"
    pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.util.*,org.atf.utils.ATFUtils" %>
<%
	String profileId = request.getParameter("profileId");
	String serverName = request.getParameter("serverName");
// 	String configProperty="";
	String nuOfLines= "200";
// 	if( profileId != null && serverName != null){
// 		configProperty=ATFUtils.getWasConfig(Integer.valueOf(profileId), serverName);
// 		nuOfLines=String.valueOf(configProperty.split(System.getProperty("line.separator")).length);
// 	}else{
// 		out.println("Input parameter are null");
// 	}
%>

<h4>Server Details</h4>

<div class="form-group">
<div class="col-lg-10">
	<div id="wasConfigurationDetailAlerts"></div>
	<div class="panel panel-default">
	  <div class="panel-heading"><a data-toggle="collapse" href="#executionSectionBody">Execution</a></div>
	  <div id="executionSectionBody" class="panel-collapse collapse">
		  <div class="panel-body">
		  	<p>The response file below will be executed against  the profile. This will change the configuration. The profile should be configured with the configuration scripts.</p>
		    <form class="form-horizontal" role="form">
		    	<div class="form-group">
				    <label for="serverName" class="col-sm-2 control-label">ServerName:</label>
				    <div class="col-sm-4">
				      <p class="form-control-static" id="wasConfigServerName"><%=serverName %></p>  
				    </div>
			 	</div>
			 	<div class="form-group">
				    <label for="configAction" class="col-sm-2 control-label">Action:</label>
				    <div class="col-sm-4">
				      <select class="form-control" id="configAction">
				      	<option></option>
				      	<option>Add</option>
						<option>Update</option>
						<option>Delete</option>
				      </select>
				    </div>
				    <label for="configTask" class="col-sm-2 control-label">Task:</label>
				    <div class="col-sm-4">
				       <select class="form-control" id="configTask">
				      	<option></option>
				      	<option>createCluster</option>
						<option>createClusterMember</option>
						<option>createJVMProperties</option>
						<option>createVirtualHost</option>
						<option>createHostAlias</option>
						<option>createWebsphereVariable</option>
						<option>createProcessExecution</option>
						<option>createChangeLogs</option>
						<option>createJ2CAuthentication</option>
						<option>createJDBCProvider</option>
						<option>createMonitorPolicy</option>
						<option>createJDBCDataSource</option>
						<option>createWillySettings</option>
						<option>createHPDiagSettings</option>
						<option>WebContainerPorts</option>
						<option>createWebSphereQCF</option>
						<option>createWebSphereQD</option>
						<option>createWebSphereLP</option>
						<option>DisableHAManager</option>
						<option>createGenericJvmArguments</option>
						<option>createJSessionId</option>
						<option>configJVMPort</option>
						<option>changeThreadPool</option>
				      </select>
				    </div>
				</div>
				<div class="form-group">   
				    <label for="configName" class="col-sm-2 control-label">Name:</label>
				    <div class="col-sm-4">
				      <input type="text" class="form-control" id="configName" placeholder="Name" disabled>
				    </div>
				    <label for="configPos" class="col-sm-2 control-label">Position:</label>
				    <div class="col-sm-4">
				      <input type="text" class="form-control" id="configPos" placeholder="Position" disabled>
				    </div>
				</div>
				<div class="pull-right">
					<button type="button" class="btn btn-primary"><i class="fa fa-play fa-fw"></i>Execute</button>
				</div>
		    </form>
		  </div>
	   </div>
	</div>
	<textarea class="form-control" id="appConfigTextArea" rows="<%=nuOfLines %>" ></textarea>
</div>
<div class="col-lg-2">
	<div class="btn-group-vertical" role="group" aria-label="Vertical button group">
			<button type="button" class="btn btn-primary" id="uploadConfigFile"><i class="glyphicon glyphicon-open fa-fw"></i>Upload</button>
			<br>
			<button type="button" class="btn btn-primary" id="refreshConfigFileData"><i class="glyphicon glyphicon-refresh fa-fw"></i>Refresh</button>
			<br>
			<button type="button" class="btn btn-primary" id="editConfigFileData"><i class="glyphicon glyphicon-edit fa-fw"></i>Edit</button>
	</div>
</div>
</div>

<script>
    $(document).ready(function() {
    	 
    	 $( "#editConfigFileData" ).click(function(){
    		var configFilePath= uft.getWasConfigFilePath(parseInt(<%= profileId %>), "<%= serverName %>")
    		
    	//	uft.updateMainContainer('../ATFConfigurator/?fileName='+configFilePath+'&type=config');
    		mywindow=window.open ("../ATFConfigurator/?fileName="+configFilePath+"&type=config","Configurator","menubar=0,toolbar=0,resizable=1,width=800,height=600");
    	 	mywindow.moveTo(100, 100);
    	   })
    	  $( "#refreshConfigFileData" ).click(function(){
    	 	refreshTextArea();
    	 })
    	  $( "#uploadConfigFile" ).click(function(){
    	 	var configFile=$("#appConfigTextArea").val();
    	 	uft.uploadWasConfigFile(parseInt(<%= profileId %>), "<%= serverName %>",configFile, "wasConfigurationDetailAlerts" );
    	 	
    	 })
    	function refreshTextArea(){
    		var configProp= uft.getWasConfigFile(parseInt(<%= profileId %>), "<%= serverName %>")
	    	if ( configProp != ""){
	    		$("#appConfigTextArea").val(configProp)
	    	}
    	}
    	refreshTextArea();
    })
</script>